//
//  EFSearchAddressCell.m
//  EnjogFood
//
//  Created by 王芳 on 17/5/9.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFSearchAddressCell.h"
#import "EFUserLocationItem.h"

@interface EFSearchAddressCell ()
@property (strong, nonatomic) UILabel *addressLabel;
@property (strong, nonatomic) UILabel *detailLabel;
@property (strong, nonatomic) UIView *line;
@end

@implementation EFSearchAddressCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI{
    [self.contentView addSubview:self.addressLabel];
    [self.contentView addSubview:self.detailLabel];
    [self.contentView addSubview:self.line];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.line.bottom = self.height;
}

- (void)setObject:(EFUserLocationItem *)item{
    self.addressLabel.text = item.address;
    [self.addressLabel sizeToFit];
    self.addressLabel.left = 21;
    self.addressLabel.top = 19;
    
    self.detailLabel.text = item.detailAddress;
    [self.detailLabel sizeToFit];
    self.detailLabel.left = self.addressLabel.left;
    self.detailLabel.top = self.addressLabel.bottom + 5;
}

- (UILabel *)addressLabel{
    if (!_addressLabel) {
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.font = [UIFont systemFontOfSize:15];
        _addressLabel.textColor = kBlack333;
    }
    return _addressLabel;
}

- (UILabel *)detailLabel{
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc] init];
        _detailLabel.font = [UIFont systemFontOfSize:15];
        _detailLabel.textColor = kBlack666;
    }
    return _detailLabel;
}

- (UIView *)line{
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 1)];
        _line.backgroundColor = RGBCOLOR(0xf5f9f9);
    }
    return _line;
}

@end
